/**
* Clase con campos y metodos generales
* asociado al 
* aplicativo.
*/
Ext.namespace('Ext.APP_GLOBAL');

if (!this.APP_GLOBAL) {
    this.APP_GLOBAL = {};
}

(function () {

    //_gServiceUrl= 'http://www.fdploja.ec/gpfdloja';
    //_gServiceUrl= 'http://www.enovatraining.ec/entgpall';
    //_gServiceUrl= 'http://localhost:8080/ENT.GP.Ws',
    if (typeof APP_GLOBAL.SERVER_URL !=="string")
        APP_GLOBAL.SERVER_URL='http://localhost:8080/EGPWFDL';
    if (typeof APP_GLOBAL.getServiceUrl !== 'function') {
        APP_GLOBAL.getServiceUrl = function () {
            var _gServiceUrl =  APP_GLOBAL.SERVER_URL+'/service.asmx/';
            return _gServiceUrl; 
        }
    }
    if (typeof APP_GLOBAL.getGoogleURL!== 'function') {
      APP_GLOBAL.getGoogleURL = function () { 
            var _gUrl= 'http://maps.google.com/maps/api/js?sensor=true';
            return _gUrl; 
        }
    }
    //Apply the 1 params
    if (typeof APP_GLOBAL.SetProxyExtraParam !== 'function') {
        APP_GLOBAL.SetProxyExtraParam = function (_store, _id, _data) {
            try {
                _store.getProxy().setExtraParam(_id, _data);


            } catch (e) { alert("Error SetProxyExtraParams: " + e.message); }

        }
    }
    //Apply the N params
    if (typeof APP_GLOBAL.SetProxyExtraParams !== 'function') {
        APP_GLOBAL.SetProxyExtraParams = function (_store, _data) {
            try {
                //store.getProxy().setExtraParam('geocode', geocode);
                Ext.apply(_store.getProxy()._extraParams, _data);

            } catch (e) { alert("Error SetProxyExtraParams: " + e.message); }

        }
    }
    if (typeof APP_GLOBAL.SetLog !== 'function') {
        APP_GLOBAL.SetLog = function (ex,type_message) {
            try {
                var type       = 2; 
                var msg_global = "";
                if (type_message!=undefined)
                    type = type_message;
                if (ex.message && ex.name) {
                    if (type == 1)
                    {
                        console.log("SomeMethod caught an exception of type " + ex.name + ": ", ex.message);
                        console.log(ex);
                    }
                    else
                    { 
                        msg_global = "SomeMethod caught an exception of type " + ex.name;
                        msg_global = msg_global+ex;
                    }

                } else 
                {
                    if (type == 1)
                        console.log("SomeMethod caught a poorly-typed exception: "+ex );
                    else
                        msg_global ="SomeMethod caught a poorly-typed exception: "+ex; 
                }
                if (type == 1)
                   console.log(ex.stack);
                else
                   msg_global = msg_global+ex.stack;

                if (type == 2)
                {
                      alert(msg_global);
                }

            } catch (e) { alert("Error SetLog: " + e.message); }

        }
    }

} ());
Ext.APP_GLOBAL = APP_GLOBAL;
